<?php
/**
 * The Company form, used for creation and edition
 * @package ModuleGestionContacts
 * @version 1.0b
 */
?>

<form action="" method ="post" class="form-crud">
<table cellpadding="0" cellspacing="0" border="0" class="form">
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle"><?php echo ($_GET['operation'] == 'edit') ? 'Entreprise '.$company->name : 'Nouvelle Entreprise'; ?></h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"><label for="company-name">Nom :</label></td>
		<td class="form-crud-input" colspan="3"><input type="text" name="company-name" value="<?php echo $company->name; ?>" /></td></tr>
	<tr>
		<td class="form-crud-label"><label for="company-activitysector">Secteur d'activité :</label></td>
		<td class="form-crud-input"><input type="text" name="company-activitysector" value="<?php echo $activitysector->name; ?>" /></td>
		<td class="form-crud-label"><label for="company-contact">Contact principal :</label></td>
		<td class="form-crud-input"><input type="text" name="company-contact" value="<?php echo $contact->lastname.' '.$contact->firstname; ?>" /></td>
	</tr>
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle">Adresse Principale</h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"><label for="address-name">Nom :</label></td>
		<td class="form-crud-input"><input type="text" name="address-name" value="<?php echo $address->name; ?>" /></td>
		<td class="form-crud-label"><label for="address-building">Bâtiment :</label></td>
		<td class="form-crud-input"><input type="text" name="address-building" value="<?php echo $address->building; ?>" /></td>
	<tr>
	<tr>
		<td class="form-crud-label"><label for="address-number">Numéro :</label></td>
		<td class="form-crud-input"><input type="text" name="address-number" value="<?php echo $address->number; ?>" /></td>
		<td class="form-crud-label"><label for="address-street">Rue :</label></td>
		<td class="form-crud-input"><input type="text" name="address-street" value="<?php echo $address->street; ?>" /></td>
	<tr>
	<tr>
		<td class="form-crud-label"><label for="address-city">Ville :</label></td>
		<td class="form-crud-input"><input type="text" name="address-city" value="<?php echo $address->city; ?>" /></td>
		<td class="form-crud-label"><label for="address-postalcode">Code Postal :</label></td>
		<td class="form-crud-input"><input type="text" name="address-postalcode" value="<?php echo $address->postalcode; ?>" /></td>
	<tr>
</table>
<br />
<input type="hidden" value="<?php echo $company->contactId; ?>" name="company-contactId" />
<input type="hidden" value="<?php echo $company->activitysectorId; ?>" name="company-activitysectorId" />
<input type="hidden" value="<?php echo $company->companyId; ?>" name="company-companyId" />
<input type="hidden" value="<?php echo $_GET['operation']; ?>" name="company-operation" />
<a href="#" id="form-company" class="submit">Sauvegarder</a>

<?php if ($_GET['operation'] != 'add'): ?>
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="form-crud-label" colspan="4"><h3 class="subtitle">Documents</h3></td>
	<tr>
	<tr>
		<td class="form-crud-label"></td>
		<td class="form-crud-input">
			<table cellpadding="0" cellspacing="0" border="0" class="documents">
			<?php
			$documentList = $company->GetDocumentList();
			foreach ($documentList as $document) {
				$res  = '<tr>';
				$res .= '<td class="del"><a href="'.$document->documentId.'" class="delete-doc"><img src="css/img/bin_empty.png" alt="Delete" /></a></td>';
				$res .= '<td><a href="'.$configuration['appdir'].'data/docs/'.$document->documentId.'.'.$document->extension.'" target="_blank" class="file">'.$document->filename.'.'.$document->extension.'</a></td>';
				$res .= '</tr>';
				echo $res;
			}
			?>
			</table>
		</td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
	<tr>
		<td class="form-crud-label"><label for="company-file-upload">Ajouter des fichiers :</label></td>
		<td class="form-crud-input"><input id="company-file-upload" name="company-file-upload" type="file" /></td>
		<td class="form-crud-label"><a href="javascript:$('#company-file-upload').uploadifyUpload()" class="upload">Upload</a></td>
		<td class="form-crud-input"></td>
	</tr>
	<tr>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
		<td class="form-crud-label"></td>
		<td class="form-crud-input"></td>
	</tr>
</table>

<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="form-crud-label"><h3 class="subtitle">Contacts professionnels</h3></td>
	<tr>
	<tr>
		<td class="form-crud-input"><?php include 'inc/gotproroles_company.php'; ?></td>
	<tr>
</table>
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="form-crud-label"><h3 class="subtitle">Contacts universitaires</h3></td>
	<tr>
	<tr>
		<td class="form-crud-input"><?php include 'inc/gotstudentactivities_company.php'; ?></td>
	<tr>
</table>
<?php endif; ?>

</form>

<div id="result"></div>

<div id="select_contact" class="hidden"></div>
<div id="select_sector" class="hidden"></div>
<div id="select_model" class="hidden"></div>